<%--
  Created by IntelliJ IDEA.
  User: HKemmm
  Date: 2022/3/10
  Time: 17:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head lang="en">
    <meta charset="utf-8"/>
    <title>鲜花时光</title>
    <link rel="stylesheet" type="text/css" href="/static/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/myorder.css"/>

    <style>
        .btn-order {
            display: block;
            width: 118px;
            height: 28px;
            line-height: 28px;
            text-align: center;
            border: 1px solid #B0B0B0;
            position: relative;
            float: right;
            top: -45px;
            margin-right: 30px;
            cursor: pointer;
        }

        .btn1 {
            background: #A10000;
            color: #fff;
            border: 1px solid #A10000;
        }

        .btn2:hover {
            background: #757575;
            color: #fff;
            transform: translate(0.5);
            cursor: pointer;
        }

        .tt {
            visibility: hidden;
        }

        .btn-o1 {
            /*line-height: 28px;*/
            /*text-align: center;*/
            /*border: 1px solid #B0B0B0;*/
            /*color: #666;*/
        }

        .fr-price {
            /*float: right;*/
            /* margin-right: 30px; */
            position: relative;
            top: 20px;
            left: 270px;
            /*min-width: 200px;*/
        }

        .fr-price span {
            font-size: 15px;
            color: #A10000;
        }
    </style>
</head>
<body>
<!------------------------------head------------------------------>
<div class="head ding">
    <div class="wrapper clearfix">
        <div class="clearfix" id="top">
            <h1 class="fl"><a href="/page/index.jsp"><img src="/static/moban/img/logo/logo.png"/></a></h1>
            <div class="fr clearfix" id="top1">
                <p class="fl">
                    <a href="#" id="login">登录</a>
                    <a href="#" id="reg">注册</a>
                </p>
                <form action="#" method="get" class="fl">
                    <input type="text" placeholder="搜索"/>
                    <input type="button"/>
                </form>
                <div class="btn fl clearfix">
                    <a href="mygxin.html"><img src="/static/img/grzx.png"/></a>
                    <a href="#" class="er1"><img src="/static/img/ewm.png"/></a>
                    <a href="cart.html"><img src="/static/img/gwc.png"/></a>
                    <p><a href="#"><img src="/static/img/smewm.png"/></a></p>
                </div>
            </div>
        </div>
        <ul class="clearfix" id="bott">
            <li><a href="index.html">首页</a></li>
            <li>
                <a href="#">所有商品</a>
                <div class="sList">
                    <div class="wrapper  clearfix">
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav1.jpg"/></dt>
                                <dd>浓情欧式</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav2.jpg"/></dt>
                                <dd>浪漫美式</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav3.jpg"/></dt>
                                <dd>雅致中式</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav6.jpg"/></dt>
                                <dd>简约现代</dd>
                            </dl>
                        </a>
                        <a href="paint.html">
                            <dl>
                                <dt><img src="/static/img/nav7.jpg"/></dt>
                                <dd>创意装饰</dd>
                            </dl>
                        </a>
                    </div>
                </div>
            </li>
            <li>
                <a href="flowerDer.html">装饰摆件</a>
                <div class="sList2">
                    <div class="clearfix">
                        <a href="proList.html">干花花艺</a>
                        <a href="vase_proList.html">花瓶花器</a>
                    </div>
                </div>
            </li>
            <li>
                <a href="decoration.html">布艺软饰</a>
                <div class="sList2">
                    <div class="clearfix">
                        <a href="zbproList.html">桌布罩件</a>
                        <a href="bzproList.html">抱枕靠垫</a>
                    </div>
                </div>
            </li>
            <li><a href="paint.html">墙式壁挂</a></li>
            <li><a href="perfume.html">蜡艺香薰</a></li>
            <li><a href="idea.html">创意家居</a></li>
        </ul>
    </div>
</div>
<!------------------------------idea------------------------------>
<div class="address mt">
    <div class="wrapper clearfix">
        <a href="#" class="fl">首页</a>
        <span>/</span>
        <a href="mygxin.html">个人中心</a>
        <span>/</span>
        <a href="myorderq.html" class="on">我的订单</a>
    </div>
</div>

<!------------------------------Bott------------------------------>
<div class="Bott">
    <div class="wrapper clearfix">
        <div class="zuo fl">
            <h3>
                <a><img class="zuo-img" src="/myimg/${sessionScope.User.photo}"/></a>
                <p class="clearfix"><span class="fl">[${sessionScope.User.name}]</span><span class="fr">[退出登录]</span></p>
                <input type="hidden" value="${sessionScope.User.id}" id="userId">
            </h3>
            <div>
                <h4>我的交易</h4>
                <ul>
                    <li><a href="/shop/car?id=${sessionScope.User.id}">我的购物车</a></li>
                    <li class="on"><a href="/jump/mysorder">我的订单</a></li>
                    <li><a href="/jump/myprod">评价晒单</a></li>
                </ul>
                <h4>个人中心</h4>
                <ul>
                    <li><a href="/shop/centre">我的中心</a></li>
                    <li><a href="/address/addressInfo?uid=${sessionScope.User.id}">地址管理</a></li>
                </ul>
                <h4>账户管理</h4>
                <ul>
                    <li><a href="/jump/mygrxx">个人信息</a></li>
                    <li><a href="/jump/remina">修改密码</a></li>
                </ul>
            </div>
        </div>
        <div class="you fl">
            <div class="my clearfix">
                <h2 class="fl">我的订单</h2>
                <a href="#" class="fl">请谨防钓鱼链接或诈骗电话，了解更多&gt;</a>
            </div>
            <div class="dlist clearfix">
                <ul class="fl clearfix" id="wa">
                    <li class="on"><a onclick="allOrder();">全部有效订单</a></li>
                    <li><a onclick="payOrder();">待支付</a></li>
                    <li><a onclick="payedOrder();">待收货</a></li>
                    <li><a onclick="overOrder();">已完成</a></li>
                </ul>
                <form action="#" method="get" class="fr clearfix">
                    <input type="text" name="" id="" value="" placeholder="请输入商品名称、订单号"/>
                    <input type="button" name="" id="" value=""/>
                </form>
            </div>
            <div id="orderInfo">

            </div>
            <div class="fenye clearfix">
                <a><img onclick="subPage()" src="/static/img/zuo.jpg"/></a>
                <a id="page">1</a>
                <input type="hidden" value="0,1,2" id="statement">
                <a><img onclick="addPage()" src="/static/img/you.jpg"/></a>
            </div>
        </div>
    </div>
</div>
<!--返回顶部-->
<div class="gotop">
    <a href="cart.html">
        <dl>
            <dt><img src="/static/img/gt1.png"/></dt>
            <dd>去购<br/>物车</dd>
        </dl>
    </a>
    <a href="#" class="dh">
        <dl>
            <dt><img src="/static/img/gt2.png"/></dt>
            <dd>联系<br/>客服</dd>
        </dl>
    </a>
    <a href="mygxin.html">
        <dl>
            <dt><img src="/static/img/gt3.png"/></dt>
            <dd>个人<br/>中心</dd>
        </dl>
    </a>
    <a href="#" class="toptop" style="display: none">
        <dl>
            <dt><img src="/static/img/gt4.png"/></dt>
            <dd>返回<br/>顶部</dd>
        </dl>
    </a>
    <p>400-800-8200</p>
</div>
<!--footer-->
<div class="footer">
    <div class="top">
        <div class="wrapper">
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot1.png"/></a>
                <span class="fl">7天无理由退货</span>
            </div>
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot2.png"/></a>
                <span class="fl">15天免费换货</span>
            </div>
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot3.png"/></a>
                <span class="fl">满599包邮</span>
            </div>
            <div class="clearfix">
                <a href="#2" class="fl"><img src="/static/img/foot4.png"/></a>
                <span class="fl">手机特色服务</span>
            </div>
        </div>
    </div>
    <p class="dibu">最家家居&copy;2013-2017公司版权所有 京ICP备080100-44备0000111000号<br/>
        违法和不良信息举报电话：188-0130-1238，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</p>
</div>
<script src="/static/js/jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/user.js" type="text/javascript" charset="utf-8"></script>

<script src="/static/js/utile.js"></script>

<script>
    var uid = $("#userId").val();


    $(function () {
        allOrder();
    });

    function allOrder() {
        $("#page").text(1);
        $("#statement").val("0,1,2");
        mainContext();
    }

    function payOrder() {
        $("#page").text(1);
        $("#statement").val("0");
        mainContext();
    }

    function payedOrder() {
        $("#page").text(1);
        $("#statement").val("1");
        mainContext();
    }

    function overOrder() {
        $("#page").text(1);
        $("#statement").val("2");
        mainContext();
    }

    function mainContext() {
        var state = $("#statement").val().split(",");

        $.ajax({
            url: "/order/getOrder",
            data: {"uid": uid, "state": state, "start": $("#page").text()},
            type: "post",
            success: function (data) {

                console.log(data);


                var context = '';

                for (var i = 0; i < data.length; i++) {

                    if (data[i].orderDetails.length == 0 || data[i].orderDetails.length == null) {
                        continue;
                    }

                    switch (data[i].order.status) {
                        case 0:
                            var c1 = '';

                            for (var j = 0; j < data[i].orderDetails.length; j++) {
                                c1 += '<div class="shohou clearfix">' +
                                    '<a href="#" class="fl"><img src="/myimg/' + data[i].orderDetails[j].goods.img + '"/></a>' +
                                    '<p class="fl"><a href="/Goods/product?id=' + data[i].orderDetails[j].goodsId + '">' + data[i].orderDetails[j].goods.name + '</a>' +
                                    '<a>' + data[i].orderDetails[j].goods.price + '元&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;' + data[i].orderDetails[j].num + '</a></p>' +
                                    '</div>';
                            }

                            context += '<div class="dkuang deng">' +
                                '<p class="one">待支付</p>' +
                                '<a class="btn-order btn1">订单详情</a>' +
                                '<a class="btn-order btn2"  href="/order/confirmOrder?id=' + data[i].order.id + '">立即支付</a>' +
                                '<div class="word clearfix">' +
                                '<ul class="fl clearfix">' +
                                '<li>' + formatDate(data[i].order.addtime) + '</li>' +
                                '<li>' + data[i].addressInfo.addreas.name + '</li>' +
                                '<li>订单号:' + data[i].order.code + '</li>' +
                                '<li>在线支付</li>' +
                                '</ul>' +
                                '<span class="fr-price">订单金额：<span>' + parseFloat(data[i].order.total).toFixed(2) + '</span>元</span>' +
                                '</div>' + c1 +
                                '</div>';
                            break;


                        case 1:
                            var c1 = '';
                            var c2 = '';

                            for (var j = 0; j < data[i].orderDetails.length; j++) {
                                if (data[i].orderDetails[j].status == 0) {
                                    c2 = '<p class="fr">' +
                                        '<a class="btn-o1">待发货中</a>' +
                                        '</p>';
                                } else {
                                    if (data[i].orderDetails[j].status == 1) {
                                        c2 = '<p class="fr">' +
                                            '<a class="btn2" onclick="receiveGoods(' + data[i].orderDetails[j].id + ',' + data[i].order.id + ')">确认收货</a>' +
                                            '</p>';
                                    } else {
                                        if (data[i].orderDetails[j].status == 2) {
                                            c2 = '<p class="fr">' +
                                                '<a class="btn-o1" href="/jump/myprod">待评论</a>' +
                                                '</p>';
                                        }
                                    }
                                }

                                c1 += '<div class="shohou clearfix">' +
                                    '<a href="#" class="fl"><img src="/myimg/' + data[i].orderDetails[j].goods.img + '"/></a>' +
                                    '<p class="fl"><a href="/Goods/product?id=' + data[i].orderDetails[j].goodsId + '">' + data[i].orderDetails[j].goods.name + '</a>' +
                                    '<a>' + data[i].orderDetails[j].goods.price + '元&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;' + data[i].orderDetails[j].num + '</a></p>' +
                                    c2 + '</div>';
                            }

                            context += '<div class="dkuang clearfix deng">' +
                                '<p class="one">待收货</p>' +
                                '<a class="btn-order btn1">订单详情</a>' +
                                // '<a class="btn-order btn2" onclick="updateOrderState(' + data[i].order.id + ',2)">确认收货</a>' +
                                '<div class="word clearfix">' +
                                '<ul class="fl clearfix">' +
                                '<li>' + formatDate(data[i].order.addtime) + '</li>' +
                                '<li>' + data[i].addressInfo.addreas.name + '</li>' +
                                '<li>订单号:' + data[i].order.code + '</li>' +
                                '<li>在线支付</li>' +
                                '</ul>' +
                                '<span class="fr-price">订单金额：<span>' + parseFloat(data[i].order.total).toFixed(2) + '</span>元</span>' +
                                '</div>' + c1 +
                                '</div>';
                            break;
                        case 2 :
                            var c1 = '';
                            var c2 = '';

                            for (var j = 0; j < data[i].orderDetails.length; j++) {
                                if (data[i].orderDetails[j].status == 2) {
                                    c2 = '<p class="fr">' +
                                        '<a class="btn2" href="/jump/myprod">待评论</a>' +
                                        '</p>';
                                } else {
                                    if (data[i].orderDetails[j].status == 3) {
                                        c2 = '<p class="fr">' +
                                            '<a class="btn-o1">已评论</a>' +
                                            '</p>';
                                    }
                                }

                                c1 += '<div class="shohou clearfix">' +
                                    '<a href="#" class="fl"><img src="/myimg/' + data[i].orderDetails[j].goods.img + '"/></a>' +
                                    '<p class="fl"><a href="/Goods/product?id=' + data[i].orderDetails[j].goodsId + '">' + data[i].orderDetails[j].goods.name + '</a>' +
                                    '<a>' + data[i].orderDetails[j].goods.price + '元&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;' + data[i].orderDetails[j].num + '</a></p>' +
                                    c2 + '</div>';
                            }

                            context += '<div class="dkuang">' +
                                '<p class="one">交易完成</p>' +
                                '<a class="btn-order btn1">订单详情</a>' +
                                '<a class="btn-order btn2 tt"></a>' +
                                '<div class="word clearfix">' +
                                '<ul class="fl clearfix">' +
                                '<li>' + formatDate(data[i].order.addtime) + '</li>' +
                                '<li>' + data[i].addressInfo.addreas.name + '</li>' +
                                '<li>订单号:' + data[i].order.code + '</li>' +
                                '<li>在线支付</li>' +
                                '</ul>' +
                                '<span class="fr-price">订单金额：<span>' + parseFloat(data[i].order.total).toFixed(2) + '</span>元</span>' +
                                '</div>' + c1 +
                                '</div>';
                            break;
                    }
                }

                $("#orderInfo").html(context);

            }
        });
    }


    function addPage() {
        var p = $("#page").text();
        p = parseInt(p) + 1;
        $("#page").text(p);

        mainContext();
    }

    function subPage() {
        var p = $("#page").text();
        p = parseInt(p) - 1;
        if (p < 1) {
            return false;
        }

        $("#page").text(p);
        mainContext();
    }


    function receiveGoods(id, oid) {

        $.ajax({
            url: "/orderDetail/receiveGoods",
            data: {"id": id, "uid": uid, "oid": oid},
            type: "post",
            success: function (data) {
                if (data == "ok") {
                    alert("操作成功！！");
                } else {
                    alert("操作失败，请稍后重试！！");
                }
                location.reload();
            }
        });
    }
</script>
</body>
</html>

